/**
 * 倒计时
 * @param {*} startDate 
 * @param {*} endDate 
 * @returns 
 */
const countDown = (startDate, endDate) => {
    let s;
    startDate = startDate;
    const newD = new Date(endDate);
    const oldT = startDate || newD;
    const data = new Date(newD.getTime() - new Date(oldT).getTime()).getTime();
    const days = Math.floor(data / (1000 * 60 * 60 * 24));
    const hours = Math.floor((data % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    const minutes = Math.floor((data % (1000 * 60 * 60)) / (1000 * 60));
    const seconds = Math.floor((data % (1000 * 60)) / 1000);
    if (days > 0) {
        s = days +
            "天 " +
            (hours < 10 ? "0" + hours : hours) +
            ":" +
            (minutes < 10 ? "0" + minutes : minutes) +
            ":" +
            (seconds < 10 ? "0" + seconds : seconds);
    } else {
        console.log(minutes)
        s =
            (hours < 10 ? "0" + hours : hours) +
            ":" +
            (minutes < 10 ? "0" + minutes : minutes) +
            ":" +
            (seconds < 10 ? "0" + seconds : seconds);
    }
    return s;
}

export {
    countDown
}